/*
 * @Author: 刘晟勇
 * @Date: 2021-10-19 18:56:34
 * @LastEditTime: 2021-10-23 17:10:28
 * @Description: 需要验证的api
 */

import axios from './require'
import qs from 'qs'

// 统一设置请求头
axios.interceptors.request.use(config => {
  config.headers['Authorization'] = sessionStorage.getItem('token')
  return config
})

export async function getUserInfo(callback) {
  const { data } = await axios.get('user/info')
  callback(data)
}

export async function getShopCartList(callback) {
  const { data } = await axios.get('cart/list')
  callback(data)
}

export async function changeShopCartList(params, callback) {
  await axios.post('cart/add', qs.stringify(params))
  callback && callback()
}

export async function delShopCartList(params, callback) {
  await axios.post('cart/del', qs.stringify(params))
  callback()
}